﻿using CPFrameWork.Global;
using CPFrameWork.Utility.DbOper;
using System;
using System.Collections.Generic;
using System.Text;

namespace BusinessManage.AccountDept
{
    public class AccountDept
    {

        public CPWebApiBaseReturnEntity SaveAccountDeptRelation(string accountUserId, string deptId)
        {
            CPWebApiBaseReturnEntity re = new CPWebApiBaseReturnEntity();
            try
            {
                DbHelper dbHelper = new DbHelper("CPYKWL", CPAppContext.CurDbType());
                IList<string> col = new List<string>();
                StringBuilder stringBuilder = new StringBuilder();
                string sql = @"insert into BD_AccountantDepRelation 
                              (UserId,DepId)
                              values
                              ('" + accountUserId + "','" + deptId + "')";
                stringBuilder.Append(sql);
                dbHelper.ExecuteNonQuery(stringBuilder.ToString());
                re.Result = true;
                return re;
            }
            catch (Exception ex)
            {
                re.Result = false;
                re.ErrorMsg = ex.Message.ToString();
                return re;
            }
        }


        public void DeleteAccountDeptRelation(string accountUserId)
        {
            DbHelper dbHelper = new DbHelper("CPYKWL", CPAppContext.CurDbType());
            StringBuilder stringBuilder = new StringBuilder();
            string sql = @"delete from dbo.BD_AccountantDepRelation where UserId='" + accountUserId + "';";
                stringBuilder.Append(sql);
            dbHelper.ExecuteNonQuery(stringBuilder.ToString());
        }

    }
}
